home *** CD-ROM | disk | FTP | other *** search
- property pmodel, pcamera, pMember, pSprite, pFriction, pRestitution, pType, pCreated, pHavok
- global gWorld
-
- on beginSprite me
- pSprite = sprite(me.spriteNum)
- pHavok = pSprite.pHavok
- pMember = pSprite.member
- pcamera = pSprite.camera
- pCreated = 0
- if voidp(pmodel) then
- pmodel = "All"
- end if
- end
-
- on endSprite me
- end
-
- on makeRigidBody me, mdlName
- bConcave = offset("Concave", pType)
- bSphere = offset("Sphere", pType)
- bBox = offset("Box", pType)
- if not getPos(pMember.model(mdlName).modifier, #meshDeform) then
- pMember.model(mdlName).addModifier(#meshDeform)
- end if
- if bConcave then
- rb = pHavok.makeFixedRigidBody(mdlName, 0)
- else
- if bSphere then
- rb = pHavok.makeFixedRigidBody(mdlName, 1, #sphere)
- else
- if bBox then
- rb = pHavok.makeFixedRigidBody(mdlName, 1, #box)
- else
- rb = pHavok.makeFixedRigidBody(mdlName)
- end if
- end if
- end if
- rb.friction = pFriction
- rb.restitution = pRestitution
- return rb
- end
-
- on enterFrame me
- if not pCreated then
- pCreated = 1
- if "All" = pmodel then
- repeat with j = 1 to pMember.model.count
- if string(pMember.model[j]) contains "model" then
- me.makeRigidBody(pMember.model[j].name)
- end if
- end repeat
- else
- repeat with i = 1 to gWorld.group("HavokTrackGroup").child.count
- me.makeRigidBody("HavokTrack_" & i)
- end repeat
- end if
- end if
- end
-
- on exitFrame me
- end
-
- on isOKToAttach aScript, aSpriteType, aSpriteNum
- case aSpriteType of
- #graphic:
- case sprite(aSpriteNum).member.type of
- #shockwave3d:
- if aScript.getmodels(sprite(aSpriteNum).member, []).count > 0 then
- return 1
- else
- return 0
- end if
- #text:
- if sprite(aSpriteNum).member.displayMode = #mode3d then
- return 1
- else
- return 0
- end if
- end case
- #script:
- return 0
- end case
- return 0
- end
-
- on getPropertyDescriptionList aScript
- if the floatPrecision < 4 then
- set the floatPrecision to 4
- end if
- if the currentSpriteNum > 0 then
- tGPDList = [:]
- tList = []
- tList = aScript.getmodels(sprite(the currentSpriteNum).member, tList)
- tList.addAt(1, "All")
- if tList.count > 1 then
- tGPDList[#pmodel] = [#comment: "Which model", #format: #string, #range: tList, #default: tList[1]]
- else
- nothing()
- pmodel = tList[1]
- end if
- tGPDList[#pRestitution] = [#comment: "Restitution", #format: #float, #default: 0.29999999999999999]
- tGPDList[#pFriction] = [#comment: "Friction", #format: #float, #default: 0.29999999999999999]
- tTypeList = ["Convex:Sphere", "Convex:Box", "Convex:Hull", "Concave"]
- tGPDList[#pType] = [#comment: "Type", #format: #string, #range: tTypeList, #default: tTypeList[3]]
- return tGPDList
- end if
- end
-
- on getBehaviorTooltip aScript
- tString1 = "Creates fixed rigid bodies from 3D models" & RETURN & RETURN
- tString2 = "-" && "Type" && ":" && "Local Action" & RETURN
- tString3 = "-" && "Usage" && ":" && "Drop this onto a scene with physics"
- return tString1 & tString2 & tString3
- end
-
- on getBehaviorDescription aScript
- tString1 = "CREATES A FIXED RIGID BODY" & RETURN & RETURN & "PARAMETERS:" & RETURN & "- Model to create rigid body from" & RETURN & "- Restitution" & RETURN & "- Friction" & RETURN & "- Type" & RETURN & "PERMITTED SPRITE TYPES:" & RETURN & "- Shockwave 3D"
- return tString1
- end
-
- on getmodels me, amember, aList
- repeat with j = 1 to amember.model.count
- if string(amember.model[j]) contains "model" then
- aList.add(amember.model[j].name)
- end if
- end repeat
- return aList
- end
-